#include<iostream>
#include<string>
#include<cmath>
using namespace std;
typedef long long LL;
const int N = 1e3 + 10;
LL f[N][N];
int n, m;
int a[N * 2];
int main()
{
	cin >> n >> m;
	int mid = n;
	for (int i = 1; i <= n; i++)cin >> a[i];
	for (int i = n + m; i >= n + 1; i--)cin >> a[i];
	n += m;
	for (int len = 1; len <= n; len++) {
		for (int i = 1; i + len - 1 <= n; i++) {
			int j = i + len - 1;
			if (i <= mid && j >= mid + 1) {
				if ((n - len) & 1)f[i][j] = min(f[i + 1][j], f[i][j - 1]);
				else f[i][j] = max(f[i + 1][j] + a[i], f[i][j - 1] + a[j]);
			}
			if (i == mid + 1) {
				if ((n - len) & 1)f[i][j] = f[i][j - 1];
				else f[i][j] = f[i][j - 1] + a[j];
			}
			if (j == mid) {
				if ((n - len) & 1)f[i][j] = f[i + 1][j];
				else f[i][j] = f[i + 1][j] + a[i];
			}
		}
	}
	cout << f[1][n] << endl;
	return 0;
}